set(X_TOOL_TMP ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB_RECURSE TOOLS_SOURCE "${X_TOOL_TMP}/*.*")
list(REMOVE_ITEM TOOLS_SOURCE "${X_TOOL_TMP}/CMakeLists.txt")

if(NOT X_TOOLS_ENABLE_MODULE_BLUETOOTH)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsBleCentralTool.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsBleCentralTool.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsBleCentralToolUi.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsBleCentralToolUi.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsBleCentralToolUi.ui)
endif()

if(NOT X_TOOLS_ENABLE_MODULE_SERIALPORT)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsSerialPortTool.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsSerialPortTool.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsSerialPortTransmitterTool.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsSerialPortTransmitterTool.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortToolUi.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortToolUi.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortToolUi.ui)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortTransmitterToolUi.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortTransmitterToolUi.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortTransmitterToolUiEditor.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortTransmitterToolUiEditor.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsSerialPortTransmitterToolUiEditor.ui)
endif()

if(NOT X_TOOLS_ENABLE_MODULE_HID)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsHidTool.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsHidTool.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsHidManager.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/Tools/xToolsHidManager.cpp)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsHidToolUi.h)
  list(REMOVE_ITEM TOOLS_SOURCE ${X_TOOL_TMP}/ToolsUI/xToolsHidToolUi.h)
endif()

add_library(xToolsTools STATIC ${TOOLS_SOURCE})
target_link_libraries(xToolsTools PUBLIC xToolsCommon Qt${QT_VERSION_MAJOR}::WebSockets)
add_dependencies(xToolsTools xToolsCommon)
x_tools_add_hid_files(xToolsTools)
x_tools_generate_translations(xToolsTools)
